﻿using LaunchAllaround.DesignPattern.MVC;
using LaunchAllaround.Engine;
using LaunchAllaround.Key;
using LaunchAllaround.Pad;
using LaunchAllaround.Playlist;
using LaunchAllaround.Sound;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace LaunchAllaround
{
    /// <summary>
    /// Logique d'interaction pour MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            //Vérifier si l'on a une configuration de playlist à ouvrir sinon, on créé une nouvelle playlist
            //créé une Playlist et inscrit son UI à sa vue ->
            PlaylistModel pl = new PlaylistModel();
            PadModel pm = new PadModel();
            pl.Add(pm);
            ((Controller<PlaylistModel>)(Kinect.Myself.GetViews().Get(2))).SetModel(pl);

            this.playlistView.Children.Add((PlaylistUI)(pl.GetViews().Get(0)));
            this.playlistMenu.Children.Add((PlaylistMenu)(pl.GetViews().Get(1)));

            this.kinectStatus.Children.Add((KinectStatusView)(Kinect.Myself.GetViews().Get(0)));
            this.kinectView.Children.Add((KinectView)(Kinect.Myself.GetViews().Get(1)));
            this.handPositionAnalyzer.Children.Add((HandPositionAnalyzer)(Kinect.Myself.GetViews().Get(2)));

            AudioSettings audiosettings = (AudioSettings)(SongPlayer.myself.GetViews().Get(0));
            this.soundView.Children.Add(audiosettings);
            this.footerView.Children.Add(Footer.myself);
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            if (SongPlayer.myself.Sequencer != null && SongPlayer.myself.Sequencer.IsAlive)
            {
                SongPlayer.myself.Sequencer.Abort();
            }
            base.OnClosing(e);
        }
 
       
    }
}
